//
//  ILVideoViewController.m
//  ILife
//
//  Created by lanou on 15/10/26.
//  Copyright © 2015年 ILife. All rights reserved.
//

#import "ILVideoViewController.h"
#import "ILDailySelectTableViewController.h"
#import "ILPastDaysViewController.h"

@interface ILVideoViewController ()
@property(nonatomic,strong)ILDailySelectTableViewController *dailySelectView;

@property(nonatomic,assign)BOOL isOpen;
@property(nonatomic,assign)BOOL isTap;
@property(nonatomic,strong)UIImageView *img;

@end

@implementation ILVideoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
///设置导航栏字体大小
//    [self.navigationController.navigationBar setTitleTextAttributes:
//  @{NSFontAttributeName:[UIFont systemFontOfSize:20],
//    NSForegroundColorAttributeName:[UIColor blackColor]}];
//    self.navigationItem.title = @"爱视频";
   
//    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2, 0, 32, 32)];
//    label.font = [UIFont fontWithName:@"Zapfino" size:20];
//    label.text = @"eyepetizer";
//    self.navigationItem.titleView = label;
    
    [[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
    
    self.navigationItem.title = @"爱生活";

    
    _img = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"more"]];
    _img.frame = CGRectMake(0, 0, 16, 16);

    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap:)];
    [_img addGestureRecognizer:tap];
    _isTap = YES;
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:_img];
    
    self.dailySelectView = [[ILDailySelectTableViewController alloc]initWithStyle:(UITableViewStylePlain)];
    

    self.dailySelectView.tableView.frame = CGRectMake(0, 64, SCREEN_WIDTH,SCREEN_HEIGHT-112);
    
    self.dailySelectView.nav = self.navigationController;
    [self.view addSubview:self.dailySelectView.tableView];
    _isOpen = NO;
    
    // 回到顶部按钮
    UIButton *topButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [topButton setImage:[UIImage imageNamed:@"top"] forState:(UIControlStateNormal)];
    topButton.frame = CGRectMake(SCREEN_WIDTH - 60, SCREEN_HEIGHT - 100, 40, 40);
    topButton.backgroundColor = [UIColor grayColor];
    topButton.alpha = 0.5;
    topButton.layer.cornerRadius = 20;
    topButton.layer.masksToBounds = YES;
    [topButton addTarget:self action:@selector(toTop) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:topButton];
    
    
}

// 返回顶部
- (void)toTop
{
    [self.dailySelectView.tableView scrollRectToVisible:CGRectMake(0, 20, 1, 1) animated:NO];
}


-(void)tap:(UITapGestureRecognizer *)tap
{
    if (_isTap) {
        [UIView animateWithDuration:0.5 animations:^{
            tap.view.transform = CGAffineTransformMakeRotation(M_PI_2);
            
        } completion:^(BOOL finished) {
            ILPastDaysViewController *pastDaysVC = [[ILPastDaysViewController  alloc]init];
            [self.navigationController pushViewController:pastDaysVC animated:YES];
        }];

 
    }
}
-(void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    _img.transform = CGAffineTransformMakeRotation(0);
    _isTap = YES;
    
}







- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
